package mx.com.sinformex.chat.core.server;

import java.util.concurrent.ThreadFactory;


/**
 * Fabrica de hilos que solo pone un nombre adecuado a cada thread que creara.
 * 
 * @author Oscar Ivan Hernandez Ventura [ oscar at sinformex dot com dot mx]
 *
 * @version $ Id : ServiceThreadfactory.java , v 1.0 03/04/2009 angellore $
 */
public class ServiceThreadfactory implements ThreadFactory {

	private String name;
	private int currentThreads;
	
	public ServiceThreadfactory(String name) {
		this.name = name;
	}
	
	public Thread newThread(Runnable runnable) {
		currentThreads++;
		return new Thread(runnable, String.format("pool-%s-%02d", name, currentThreads));
	}

}
